package com.wenli.lt.util;

/**
 * @author xy
 * 2019/5/19
 */
public class CommonResponse<T> {

    public final static String SUCCESS_INFO = "ok";
    public final static int ERROR_CODE = 500;
    public final static int PERMISSION_DENIED_CODE = 403;

    /**
     * 返回编号
     */
    private int errorCode;
    /**
     * 提示语
     */
    private String errorMessage;
    /**
     * 数据
     */
    private T data;

    public CommonResponse() {
    }

    public CommonResponse(T data) {
        this.errorCode = 0;
        this.errorMessage = null;
        this.data = data;

    }


    public CommonResponse(int errorCode, String errorMessage) {
        this.errorCode = errorCode;
        this.errorMessage = errorMessage;
        this.data = null;
    }

    public CommonResponse(int errorCode, String errorMessage, T data) {
        this.data = data;
        this.errorCode = errorCode;
        this.errorMessage = errorMessage;
    }


    public int getErrorCode() {
        return this.errorCode;
    }

    public void setErrorCode(int errorCode) {
        this.errorCode = errorCode;
    }

    public String getErrorMessage() {
        return this.errorMessage;
    }

    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }

    public T getData() {
        return this.data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public String toString() {
        return "CommonResponse{errorCode=" + this.errorCode + ", errorMessage='" + this.errorMessage + '\'' + ", data=" + this.data + '}';
    }
}
